package net.steamcrafted.materialiconlib.factory;

import net.steamcrafted.materialiconlib.MaterialIconView;
import ohos.app.Context;

public class MaterialIconViewBuilder {

    private Context context;
    /**图片资源*/
    private int mResId;
    /**icon 颜色*/
    private int mIconColor;
    /**背景颜色*/
    private int mBackgroundColor;
    /**组件圆角半径*/
    private int mRadius;
    /**组件 padding*/
    private int mPadding;
    /**组件宽高*/
    private int mWidth;
    /**组件高度*/
    private int mHeight;
    /**是否是圆形 Icon*/
    private boolean isCircular;

    private MaterialIconViewBuilder(Context context) {
        this.context = context;
    }

    public static MaterialIconViewBuilder with(Context context){
        return new MaterialIconViewBuilder(context);
    }

    public void setResId(int mResId) {
        this.mResId = mResId;
    }

    public void setIconColor(int mIconColor) {
        this.mIconColor = mIconColor;
    }

    public void setBackgroundColor(int mBackgroundColor) {
        this.mBackgroundColor = mBackgroundColor;
    }

    public void setRadius(int mRadius) {
        this.mRadius = mRadius;
    }

    public void setPadding(int mPadding) {
        this.mPadding = mPadding;
    }

    public void setWidth(int mWidth) {
        this.mWidth = mWidth;
    }

    public void setHeight(int mHeight) {
        this.mHeight = mHeight;
    }

    public void setCircular(boolean circular) {
        isCircular = circular;
    }

    public MaterialIconView build(){

        return (MaterialIconView)new MaterialIconView(context)
                .set_ResId(mResId)
                .set_radius(mRadius)
                .set_padding(mPadding)
                .set_iconColor(mIconColor)
                .set_CircularComponent(isCircular)
                .setSize(Math.min(mWidth, mHeight))
                .set_backgroundColor(mBackgroundColor);
    }
}
